import cv2
from utils.common import load_image, load_image1, show_image, make_dirs  # 导入公共函数
from utils.config import exp5_gray_path2, exp5_gray_path1, exp5_output_dir  # 导入输出路径

# 确保输出目录存在
make_dirs(exp5_output_dir)

# 加载图片并显示
image = load_image()
image1 = load_image1()

# 灰度化
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray_image1 = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)

#展示图片
show_image("Grayscale Image", gray_image)
show_image("Grayscale Image1", gray_image1)

# 保存结果
cv2.imwrite(exp5_gray_path2, gray_image)
cv2.imwrite(exp5_gray_path1, gray_image1)
print(f"灰度化结果已保存到：{exp5_gray_path2, exp5_gray_path1}")